home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cracking 2
/
Cracking II..iso
/
Tools
/
ApiHooks 3.0
/
MODAPIS.INC
< prev
next >
Wrap
Text File
|
2000-06-18
|
6KB
|
180 lines
;------------------------------------------------------------------------
;These exported functions and EAH* functions work identically. They
;prepare Block for remote execution then they call RemoteExecute.
;Following "Module APIs" work with remote code stored in ModWorks.inc.
;ModModes:
IsModule = 0
UnloadModule = 1
LoadCall = 2
;------------------------------------------------------------------------
;Stubs:
PUBLIC IsModuleLoadedA
IFDEF NOOPT
IsModuleLoadedA PROC lpszDll, procID
sWin32 WorkModule, lpszDll, procID, 1, NULL, IsModule, FALSE
RET
ELSE
IsModuleLoadedA PROC
PUSH FALSE
JMP WKMODI
ENDIF
IsModuleLoadedA ENDP
;---------------------------------------------
PUBLIC IsModuleLoadedW
IFDEF NOOPT
IsModuleLoadedW PROC lpszDll, procID
sWin32 WorkModule, lpszDll, procID, 1, NULL, IsModule, TRUE
RET
ELSE
IsModuleLoadedW PROC
PUSH TRUE
WKMODI::
sWin32 WorkModule, [ESP+24], [ESP+24], 1, NULL, IsModule
RETN 8
ENDIF
IsModuleLoadedW ENDP
;------------------------------------------------------------------------
PUBLIC LoadAndCallA
IFDEF NOOPT
LoadAndCallA PROC lpszDll, procID, NoTries, ApiName
sWin32 WorkModule, lpszDll, procID, NoTries, ApiName, LoadCall, FALSE
RET
ELSE
LoadAndCallA PROC
PUSH FALSE
JMP WKMODL
ENDIF
LoadAndCallA ENDP
;---------------------------------------------
PUBLIC LoadAndCallW
IFDEF NOOPT
LoadAndCallW PROC lpszDll, procID, NoTries, ApiName
sWin32 WorkModule, lpszDll, procID, NoTries, ApiName, LoadCall, TRUE
RET
ELSE
LoadAndCallW PROC
ENDIF
PUSH TRUE
WKMODL::
sWin32 WorkModule, [ESP+24], [ESP+24], [ESP+24], [ESP+24], LoadCall
RETN 16
LoadAndCallW ENDP
;------------------------------------------------------------------------
PUBLIC UnloadModuleA
IFDEF NOOPT
UnloadModuleA PROC lpszDll, procID, NoTries
sWin32 WorkModule, lpszDll, procID, NoTries, NULL, UnloadModule, FALSE
RET
ELSE
UnloadModuleA PROC
PUSH FALSE
JMP WKMODU
ENDIF
UnloadModuleA ENDP
;---------------------------------------------
PUBLIC UnloadModuleW
IFDEF NOOPT
UnloadModuleW PROC lpszDll, procID, NoTries
sWin32 WorkModule, lpszDll, procID, NoTries, NULL, UnloadModule, TRUE
RET
ELSE
UnloadModuleW PROC
PUSH TRUE
WKMODU::
sWin32 WorkModule, [ESP+24], [ESP+24], [ESP+24], NULL, UnloadModule
RETN 12
ENDIF
UnloadModuleW ENDP
;------------------------------------------------------------------------
;Prepares remote code in ModWorks.inc for RemoteExecute.
WorkModule PROC USES EBX ESI EDI, lpszDll, procID, NoTries, CallApiName, ModMode, IsUnicode
sWin32 RemoteAlloc9x, UnloadSize, 0 ;allocate help memory in me
TEST EAX, EAX
MOV EDI, EAX
oMOV EAX, ErrorException
JE WMExit ;can't allocate
PUSH EDI
oLEA ESI, UnloadScout
oMOV ECX, UnloadSize0/4
REP MOVSD ;copy the remote code
POP EBX
MOV ESI, lpszDll
;copy module name then api name
NextRound:
CMP IsUnicode, ECX
JE CopyDll
iWin32 WideCharToMultiByte, ECX, ECX, ESI, -1, EDI, MAX_PATH, ECX, ECX
TEST EAX, EAX
PUSH EDI
WMErrExc:
POP EDI
oMOV EAX, ErrorException
JE WMFreeExit
PUSH EDI
JMP WMGoOn
CopyDll:
PUSH EDI
MOV ECX, MAX_PATH
@@:
LODSB
STOSB
TEST AL, AL
JE WMGoOn
DEC ECX
JE WMErrExc
JMP @B
WMGoOn:
POP EDI
SUB ECX, ECX
ADD EDI, MAX_PATH
MOV ESI, CallApiName ;what to call for LoadAndCall
CMP ECX, ESI
MOV CallApiName, ECX
JE FinCopy ;no CallApiName or was already copied
MOV [EDI], ESI
CMP ESI, 10000H ;is it ordinal?
JB FinCopy
MOV [EDI], CL ;no -> put zero at the end of the string
JMP NextRound ;and copy/convert CallApiName
FinCopy:
MOV ECX, ModMode
MOV [EBX][_CallDllApi-UnloadScout], ESI
MOV EAX, NoTries
JECXZ GoIsModule
;patch jumps and apis in remote code according to chosen function:
GoUnloadModule:
DEC ECX
JNE GoLoadModule
MOV BYTE PTR [EBX][_JEJL-UnloadScout], 7CH ;JE -> JL
MOV BYTE PTR [EBX][FreeLib-UnloadScout-1], (FreeLib-FreeLib) ;JMP NextLoop -> JMP Freelib
JMP @F
GoLoadModule:
oMOV [EBX][_DllOperation-UnloadScout], _LoadLibraryA ;GetModuleHandle -> LoadLibrary
MOV WORD PTR [EBX][_JEJL-UnloadScout], 75H+ (NextLoop-ToCallProc) SHL 8 ;JE -> JNE
MOV BYTE PTR [EBX][ToCallProc-UnloadScout+1], (CallProc-FreeLib) ;JMP NextLoop -> JMP ToCallProc
GoIsModule:
@@:
MOV [EBX][_UnloadCount-UnloadScout], EAX ;how many times to perform the module operation
sWin32 IsProcessInitializedOrNotNT, procID ;determine ForceRT
;execute the code
LEA ECX, [EBX][UnloadStop-UnloadScout] ;locate CodeEnd
sWin32 RemoteExecute, procID, MODULE_TIME, EBX, UnloadSize, ECX, EAX
WMFreeExit:
PUSH EAX
sWin32 RemoteFree9x, EBX ;free help memory in me
POP EAX
WMExit:
RET
WorkModule ENDP
;=================================================================================